#!/ur/bin/env python
#!coding=utf-8

from  greecket.factory import Greecket,CollaboratePeer
from greecket.greeevent import *
Greecket(collaborate=True)

def dataReceived(data):
    p,d,o=data.AsList
    print 'dataReceived:',[p,d,o]

def made(evt):
    print 'connectionMade',evt

def error(err):
    print 'error:',err.AsList#,dir(err)
    
def close(evt):
    print 'conntionLost',evt.AsList

p=CollaboratePeer()

p.listen(('localhost',5423))

p.bind(GREE_DATARECEIVED,dataReceived)
p.bind(GREE_ERROR,error)
p.bind(GREE_ONLINE,made)
p.bind(GREE_CONNECTIONLOST,close)
print 'greecket test,listen on ("localhost",5423)'
print p
Greecket.mainloop()
